/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.revivius.jbtorrent.parse;

import com.revivius.jbtorrent.entity.Torrent;
import java.nio.charset.Charset;
import java.util.List;
import org.ardverk.coding.BencodingUtils;

/**
 *
 * @author Revivius
 */
interface KeyParser {

    void parse(String key, Object value, Torrent torrent) throws Exception;

    static String fromByteArray(Object o) {
        return new String((byte[]) o, Charset.forName(BencodingUtils.UTF_8));
    }
    
    static String fromList(Object o) {
        return new String(((List<byte[]>) o).get(0), Charset.forName(BencodingUtils.UTF_8));
    }

}
